﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.BLL;
using Automobile.service.Model;

namespace Automobile.service.UI
{
    public partial class WareHose_list : System.Web.UI.Page
    {
        WareHoseBLL bll = new WareHoseBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                RepeterDataSource();
            }
        }

        protected void RepeterDataSource()
        {
            Repeater1.DataSource = bll.ShowListWareHose();
            Repeater1.DataBind();
            Label1.Text = bll.GetWareHoseCount().ToString();
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string ename = e.CommandName;//获取当前要执行的命令
            string id = e.CommandArgument.ToString();
            switch (ename)
            {
                case "del":
                    if (bll.DelWareHose(id) > 0)
                    {
                        JournalBLL jbll = new JournalBLL();
                        jbll.AddJourna_DelWareHose(Convert.ToInt32(Session["empid"]),id);
                        Response.Write("<script>alert('删除成功')</script>");
                        RepeterDataSource();
                    }
                    break;
            }
        }
        protected void Unnamed_ServerClick(object source,EventArgs e)
        {
            string whname = Request.Form["WareHose_Name"].ToString();
            Repeater1.DataSource = bll.GetWareHoseByName(whname);
            Repeater1.DataBind();
        }
    }
}